<template>
  <div class="p-2">
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div v-show="showSearch" class="mb-[10px]">
        <!-- <el-card shadow="hover">
          <el-form ref="queryFormRef" :model="queryParams" :inline="true">
            <el-form-item label="报告ID" prop="reportId">
              <el-input v-model="queryParams.reportId" placeholder="请输入报告ID" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="领域" prop="field">
              <el-input v-model="queryParams.field" placeholder="请输入领域" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
        </el-card> -->
      </div>
    </transition>

    <el-card shadow="never">
      <template #header>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <!-- <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:dissent:export']">导出</el-button> -->
          </el-col>
          <right-toolbar v-model:showSearch="showSearch" :search="false" @queryTable="getList"></right-toolbar>
        </el-row>
      </template>

      <el-table v-loading="loading" border :data="blackList">
        <el-table-column label="主体名称" prop="cnrmc" width="200" show-overflow-tooltip />
        <el-table-column label="主体类型" align="center" prop="cnrlb" width="120" />
        <el-table-column label="主体代码" align="center" prop="cnrdm" width="200" />
        <el-table-column label="承诺类型" align="center" prop="cnlx" width="120" />
        <el-table-column label="承诺状态" align="center" prop="cnlxzt" width="120" />
        <el-table-column label="承诺内容" prop="cnnr" min-width="200" show-overflow-tooltip />
        <el-table-column label="承诺时间" align="center" prop="promiseDate" width="160" />
      </el-table>

      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
    </el-card>
  </div>
</template>

<script setup name="Dissent" lang="ts">
import { getBlackList } from '@/api/xydz/black/index';
import { DissentVO } from '@/api/xydz/black/types';

const { proxy } = getCurrentInstance() as ComponentInternalInstance;

const blackList = ref<DissentVO[]>([]);
const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);

const queryFormRef = ref<ElFormInstance>();

const state = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10
  }
});

const { queryParams } = toRefs(state);

/** 查询异议信息列表 */
const getList = async () => {
  loading.value = true;
  const res = await getBlackList(queryParams.value);
  blackList.value = res.rows;
  total.value = res.total;
  loading.value = false;
};

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  handleQuery();
};

onMounted(() => {
  getList();
});
</script>
